﻿Imports System.Text.RegularExpressions

''' <summary>
''' 计算表达式
''' </summary>
Public Interface IEvalService


    ''' <summary>
    ''' 存在变量标志
    ''' </summary>
    ''' <returns> str 中存在 # 或 @ 返回 True, 否则返回 False</returns>
    Function ExistsFlag(ByRef str As String) As Boolean


    ''' <summary>
    ''' 是表达式
    ''' </summary>
    ''' <param name="str"></param>
    ''' <returns></returns>
    Function IsExpression(ByRef str As String) As Boolean


    ''' <summary>
    ''' 计算表达式
    ''' </summary>
    ''' <param name="str"></param>
    ''' <returns></returns>
    Function Eval(ByRef str As String) As Object


    ''' <summary>
    ''' 获得正则值
    ''' </summary>
    ''' <param name="str"></param>
    ''' <param name="pattern"></param>
    ''' <returns></returns>
    Function GetMatch(ByRef str As String, ByRef pattern As String) As Match
    Function GetMatch_ByParent(ByRef str As String) As Match
    Function GetMatch_ByMember(ByRef str As String) As Match

    ''' <summary>
    ''' 获取完整值
    ''' </summary>
    ''' <returns></returns>
    Function GetMatchFullValue(ByRef match As Match) As String

    ''' <summary>
    ''' 获取不带符号的值
    ''' </summary>
    ''' <param name="match"></param>
    ''' <returns></returns>
    Function GetMatchValue(ByRef match As Match) As String

    ''' <summary>
    ''' 解析表达式
    ''' </summary>
    ''' <param name="expr"> 表达式 </param>
    ''' <param name="self"> 自身对象 </param>
    ''' <param name="parent"> 父对象 </param>
    ''' <returns></returns>
    Function AnalyzeExpressions_ByDict(ByRef expr As String, ByRef self As Dictionary(Of String, String), Optional ByRef parent As Dictionary(Of String, String) = Nothing) As Object

    ''' <summary>
    ''' 解析表达式
    ''' </summary>
    ''' <param name="expr"> 表达式 </param>
    ''' <param name="parent"> 父对象 </param>
    ''' <returns></returns>
    Function AnalyzeExpressions_ByDict(ByRef expr As String, ByRef parent As Dictionary(Of String, Object)) As Object

    ''' <summary>
    ''' 解析表达式
    ''' </summary>
    ''' <param name="expr"> 表达式 </param>
    ''' <param name="self"> 自身对象 </param>
    ''' <param name="parent"> 父对象 </param>
    ''' <returns></returns>
    Function AnalyzeExpressions_ByEntity(ByRef expr As String, ByRef self As IDataEntity, Optional ByRef parent As IDataEntity = Nothing) As Object

    ''' <summary>
    ''' 解析表达式
    ''' </summary>
    ''' <param name="expr"> 表达式 </param>
    ''' <param name="self"> 自身对象 </param>
    ''' <param name="parent"> 父对象 </param>
    ''' <returns></returns>
    Function AnalyzeExpressions_ByDatarow(ByRef expr As String, ByRef self As DataRow, Optional ByRef parent As DataRow = Nothing) As Object

End Interface
